<?php
/**
 * Created by PhpStorm.
 * User: zhanglihe
 * Date: 17/11/2
 * Time: 下午6:29
 */
namespace App\Models;

use App\Sms;
use Illuminate\Database\Eloquent\Model;

class SmsLog extends Model
{
    protected $table = 'sms_log';

    public $guarded = [];

    public static function success($mobile, $text, $result, $ip, $tpl)
    {
        SmsLog::create([
            'mobile' => $mobile,
            'text' => $text,
            'is_success' => 1,
            'result' => json_encode($result, JSON_UNESCAPED_UNICODE),
            'ip' => $ip,
            'action' => Sms::$tplName[$tpl] ?? ''
        ]);
    }

    public static function fail($mobile, $text, $result, $ip, $tpl)
    {
        SmsLog::create([
            'mobile' => $mobile,
            'text' => $text,
            'is_success' => 0,
            'result' => json_encode($result, JSON_UNESCAPED_UNICODE),
            'ip' => $ip,
            'action' => Sms::$tplName[$tpl] ?? ''
        ]);
    }

}